﻿<UserControl x:Class="GSF.TimeSeries.UI.UserControls.NodeUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" d:DesignHeight="650" d:DesignWidth="850"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:uc="clr-namespace:GSF.TimeSeries.UI.UserControls"
             xmlns:tsfBinding="clr-namespace:GSF.TimeSeries.UI.Binding;assembly=GSF.TimeSeries.UI"
             Background="Transparent">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/GSF.TimeSeries.UI.WPF;Component/Resources/CommonResource.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <StackPanel Orientation="Vertical">

        <StackPanel.Resources>
            <CollectionViewSource Source="{Binding Path=CompanyLookupList}" x:Key="CompanyLookupList"/>
        </StackPanel.Resources>

        <Grid x:Name="GridDetailView" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="5" DataContext="{tsfBinding:Column Path=CurrentItem}" DataContextChanged="GridDetailView_DataContextChanged">
            <Grid.BindingGroup >
                <BindingGroup Name="input"/>
            </Grid.BindingGroup>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" >
                <TextBlock Text="Name" Style="{StaticResource RequiredLabel}" />
                <TextBlock Style="{StaticResource RequiredMarker}" />
            </StackPanel>
            <TextBox Grid.Row="1" Grid.Column="1" Text="{tsfBinding:Column Path=Name}" MaxLength="100"/>
            <TextBlock Text="Company" Grid.Row="1" Grid.Column="2" />
            <ComboBox Grid.Row="1" Grid.Column="3" ItemsSource="{Binding Source={StaticResource CompanyLookupList}}" DisplayMemberPath="Value"
                      SelectedItem="{tsfBinding:Column Path=CompanyID, Converter={StaticResource DictionaryToKeyValuePairConverter}, ConverterParameter={StaticResource CompanyLookupList}}"/>
            <TextBlock Text="Longitude" Grid.Row="2" Grid.Column="0" />
            <TextBox Grid.Row="2" Grid.Column="1" Text="{tsfBinding:Column Path=Longitude}" />
            <TextBlock Text="Latitude" Grid.Row="2" Grid.Column="2" />
            <TextBox Grid.Row="2" Grid.Column="3" Text="{tsfBinding:Column Path=Latitude}" />
            <TextBlock Text="Description" Grid.Row="3" Grid.Column="0" VerticalAlignment="Top" />
            <TextBox Grid.Row="3" Grid.Column="1" Text="{tsfBinding:Column Path=Description}" TextWrapping="Wrap" />
            <TextBlock Text="Image" Grid.Row="3" Grid.Column="2" VerticalAlignment="Top" />
            <TextBox Grid.Row="3" Grid.Column="3" Text="{tsfBinding:Column Path=Image}"/>
            <TextBlock Grid.Row="4" Grid.Column="0" Text="Settings"/>
            <TextBox Grid.Row="4" Grid.Column="1" Text="{tsfBinding:Column Path=Settings}" Grid.ColumnSpan="3" Width="475" Height="55" TextWrapping="Wrap" ScrollViewer.VerticalScrollBarVisibility="Visible" />
            <TextBlock Grid.Row="5" Grid.Column="0" Text="Menu Type"/>
            <TextBox Grid.Row="5" Grid.Column="1" Text="{tsfBinding:Column Path=MenuType}" MaxLength="200"/>
            <TextBlock Grid.Row="5" Grid.Column="2" Text="Menu Data"/>
            <TextBox Grid.Row="5" Grid.Column="3" Text="{tsfBinding:Column Path=MenuData}"/>
            <StackPanel Orientation="Horizontal" Grid.Row="7" Grid.Column="0" HorizontalAlignment="Right">
                <TextBlock Text="Load Order" Style="{StaticResource RequiredLabel}" />
                <TextBlock Style="{StaticResource RequiredMarker}" />
            </StackPanel>
            <TextBox Grid.Row="7" Grid.Column="1" Text="{tsfBinding:Column Path=LoadOrder}" Width="35" />
            <CheckBox Content="Master" Grid.Row="7" Grid.Column="2" IsChecked="{tsfBinding:Column Path=Master}"/>
            <CheckBox Content="Enabled" Grid.Row="7" Grid.Column="3" IsChecked="{tsfBinding:Column Path=Enabled}"/>
        </Grid>

        <uc:DetailViewFooterUserControl x:Name="UserControlDetailViewFooter" DeleteCommand="{Binding DeleteCommand}" ClearCommand="{Binding ClearCommand}" SaveCommand="{Binding SaveCommand}"
                SaveEnabled="{tsfBinding:DataOperation Path=(Validation.HasError)}" />

        <sdk:DataGrid x:Name="DataGridList" ItemsSource="{Binding CurrentPage}" SelectedItem="{Binding Path=CurrentItem, Mode=TwoWay}" Height="Auto" PreviewKeyDown="DataGrid_PreviewKeyDown"
                      Sorting="DataGrid_Sorting" SelectedIndex="{tsfBinding:Column Path=CurrentSelectedIndex}">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTextColumn Header="Node ID" Width="3*" Binding="{tsfBinding:Column Path=ID}" IsReadOnly="True"/>
                <sdk:DataGridTextColumn Header="Name" Width="2*" Binding="{tsfBinding:Column Path=Name}" />
                <sdk:DataGridCheckBoxColumn Header="Master" Width="*" Binding="{tsfBinding:Column Path=Master}" />
                <sdk:DataGridCheckBoxColumn Header="Enabled" Width="*" Binding="{tsfBinding:Column Path=Enabled}" />
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>

        <uc:DataPagerUserControl CurrentPageNumber="{Binding CurrentPageNumber}" PageCount="{Binding PageCount}"
                                 FirstCommand="{Binding FirstCommand}" PreviousCommand="{Binding PreviousCommand}"
                                 NextCommand="{Binding NextCommand}" LastCommand="{Binding LastCommand}"/>
    </StackPanel>
</UserControl>
